//
//  PEBatteryCellTableViewCell.m
//  RuiHeAppApp
//
//  Created by Yan Chen on 2023/10/27.
//

#import "RHBatteryCellItemCell1.h"
@interface RHBatteryCellItemCell1()

@end
@implementation RHBatteryCellItemCell1

-(instancetype)initWithFrame:(CGRect)frame
{
    if(self = [super initWithFrame:frame]){
        [self setupUI];
    }
    return self;
}

- (void)setPackModel:(RHDevPackModel *)packModel
{
    _packModel = packModel;
    if(packModel.status == 1){
        self.stateImg.image = [UIImage imageNamed:@"dev_me_pack_fault"];
        self.stateLab.text = @"Fault";
    }else{
        self.stateImg.image = [UIImage imageNamed:@"dev_me_pack_normal"];
        self.stateLab.text = @"Normal";
    }
    
    if(packModel.isSelected){
        self.bgView.backgroundColor = kCOLOR_HEX(@"#405DBE");
        self.packNoLab.textColor = kCOLOR_HEX(@"ffffff");
    }else{
        self.bgView.backgroundColor = kCOLOR_HEX(@"ffffff");
        self.packNoLab.textColor = kCOLOR_HEX(@"#171A1D");
    }
    
}

-(void)setupUI
{
    kWeakSelf;
    self.contentView.backgroundColor = CFTabViewBgColor;
    UIView *bgView = kView;
    bgView.backgroundColor = [UIColor whiteColor];
    bgView.layer.cornerRadius = 8;
    bgView.layer.masksToBounds = YES;
    [self.contentView addSubview:bgView];
    self.bgView = bgView;
    
    [bgView mas_makeConstraints:^(MASConstraintMaker *make) {
        make.edges.insets(UIEdgeInsetsZero);
    }];
    
    _stateImg = [[UIImageView alloc]init];
    _stateImg.layer.cornerRadius = 5;
    _stateImg.layer.masksToBounds = YES;
    [bgView addSubview:_stateImg];
    [_stateImg mas_makeConstraints:^(MASConstraintMaker *make) {
        make.width.height.offset(kScaleW(25));
        make.centerX.mas_offset(0);
        make.top.mas_offset(15);
    }];
    
    _stateLab = [[QMUILabel alloc]init];
    _stateLab.text = @"Normal";
    _stateLab.font = [UIFont systemFontOfSize:13];
    _stateLab.textAlignment = NSTextAlignmentLeft;
    _stateLab.textColor = kCOLOR_HEX(@"3F4443");
    _stateLab.hidden = YES;
    [bgView addSubview:_stateLab];
    
    _packNoLab = [[QMUILabel alloc]init];
    _packNoLab.text = @"--";
    _packNoLab.font = [UIFont systemFontOfSize:12];
    _packNoLab.textAlignment = NSTextAlignmentCenter;
    _packNoLab.textColor = kCOLOR_HEX(@"3F4443");
    [bgView addSubview:_packNoLab];
    
    [_stateLab mas_makeConstraints:^(MASConstraintMaker *make) {
        make.left.equalTo(weakSelf.stateImg.mas_right).offset(5);
        make.centerY.equalTo(weakSelf.stateImg);
    }];
    
   
    [_packNoLab mas_makeConstraints:^(MASConstraintMaker *make) {
        make.left.mas_offset(5);
        make.top.equalTo(weakSelf.stateImg.mas_bottom).offset(8);
        make.right.mas_offset(-5);
    }];
    
   
}
@end
